package com.zero.xiaodai.utils;

import java.io.IOException;
import java.util.Properties;



public class MongoProperties {
	 //mongodb服务地址
     public static String MONGO_HOST;
     //用户名
     public static String MONGO_USERNAME;
     //密码
     public static String MONGO_PASSWORD;
     //数据库端口
     public static int MONGO_PORT;
     //每个主机的连接
     public static int PERHOST_SIZE;
     //socket 保持长连接
     public static boolean ISKEEPLIVE;
     //最大等待时间
     public static int MAXWAIT_TIME;
     //连接超时
     public static int CONNECT_TIMEOUT;
     //socket连接超时
     public static int SOCKET_TIMEOUT;
     //线程队列长度
     public static int THREADSALLOWEDTOBLOCKFORCONNECTIONMULTIPLIER;
     //db name
     public static String DB_NAME;
     //collections name
     public static String COLLECTIONS_NAME;
     //nginx_path : server+port+nginx_path+imgUrl
     public static String NGINX_PATH;
     static {
    	Properties prop = new Properties();
    	try {
			prop.load(MongoProperties.class.getClassLoader().getResourceAsStream("properties/"+"mongodb.properties"));
		} catch (IOException e) {
			e.printStackTrace();
		} 
 		MONGO_HOST= prop.getProperty("mongoHost");
 		MONGO_USERNAME=prop.getProperty("mongoUserName");
 		MONGO_PASSWORD=prop.getProperty("mongoPassword");
 		MONGO_PORT= Integer.parseInt(prop.getProperty("mongoPort"));
 		PERHOST_SIZE=Integer.parseInt(prop.getProperty("perHostSize"));
 		ISKEEPLIVE=Boolean.valueOf(prop.getProperty("isKeepLive"));
 		MAXWAIT_TIME=Integer.parseInt(prop.getProperty("maxWaitTime"));
 		CONNECT_TIMEOUT=Integer.parseInt(prop.getProperty("connectTimeout"));
 		SOCKET_TIMEOUT=Integer.parseInt(prop.getProperty("socketTimeout"));
 		THREADSALLOWEDTOBLOCKFORCONNECTIONMULTIPLIER=Integer.parseInt(
 				prop.getProperty("threadsAllowedToBlockForConnectionMultiplier"));
 		DB_NAME=prop.getProperty("dbName");
 		COLLECTIONS_NAME=prop.getProperty("collectionsName");
 		NGINX_PATH=prop.getProperty("nginxPath");
     }
  
}
